package ro.pub.cs.stadium.document;

public class Size implements Cloneable {
	public float width = 0.0f;
	public float height = 0.0f;
	
	public Size() {
		
	}
	
	public Size(float width, float height) {
		this.width = width;
		this.height = height;
	}
	
	@Override
	public Size clone() {
		return new Size(this.width, this.height);
	}
	
	@Override
	public String toString() {
		return String.format("%1$f;%2$f", width, height);
	}
	
	public static Size parseSize(String s) {
		int scPos = s.indexOf(';'); // The position of the semicolon
		if (scPos < 0) {
			throw new IllegalArgumentException();
		}
		
		String ws = s.substring(0, scPos);
		String hs = s.substring(scPos+1);
		
		return new Size(
				Float.parseFloat(ws),
				Float.parseFloat(hs)
				);
	}
}
